import { IPSChartCoordinateSystemCartesian2D } from './ipschart-coordinate-system-cartesian2-d';
import { IPSChartGrid } from './ipschart-grid';
import { PSDEChartCoordinateSystemImplBase } from './psdechart-coordinate-system-impl-base';

export class PSDEChartCoordinateSystemCartesian2DImpl extends PSDEChartCoordinateSystemImplBase implements IPSChartCoordinateSystemCartesian2D {
  protected pschartgrid: IPSChartGrid | null = null;

  getPSChartGrid(): IPSChartGrid | null {
    if (this.pschartgrid != null) return this.pschartgrid;
    const value = this.M.getPSChartGrid;
    if (value == null) {
      return null;
    }
    this.pschartgrid = this.getPSModel4('control.chart.IPSChartGrid', value, 'getPSChartGrid') as IPSChartGrid;
    return this.pschartgrid;
  }

  get psChartGrid(): IPSChartGrid | null {
    return this.getPSChartGrid();
  }

  getPSChartGridMust(): IPSChartGrid {
    const value = this.getPSChartGrid();
    if (value == null) {
      throw new Error('未指定直角坐标绘图网格对象');
    }
    return value;
  }

  get cls(): string {
    return 'PSDEChartCoordinateSystemCartesian2DImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.chart.IPSChartCoordinateSystemCartesian2D') return true;
    return super.instanceof(cls);
  }
}
